home *** CD-ROM | disk | FTP | other *** search
- /*
- * The original copyright owners of the accompanying source code files have
- * agreed to place such code into the public domain. Accordingly, anyone
- * who receives or obtains a copy of such source code is freely entitled to
- * reproduce, use and otherwise exploit such code (including the right to
- * make derivative works), at his/her own risk and expense, without any
- * obligation or liability to the original copyright owners.
- *
- * We would appreciate (but do not require) that the following message be
- * included in any derivative works:
- *
- * "Portions of this program were developed by Peter Broadwell, Rob Myers
- * and Robin Schaufler while working in Silicon Valley."
- *
- * The accompanying source code files and related documentation materials
- * are distributed on an "AS IS" basis, without any warranties or
- * guarantees of any kind. All implied warranties, including the implied
- * warranties of merchantability and of fitness for any particular purpose,
- * are expressly disclaimed.
- */
- #include <stdio.h>
- #include "class.h"
-
- char * lastClass = 0;
- char * lastSelector = 0;
- char * lastReceiver = 0;
-
- /*
- * instance message dispatcher
- */
- char *
- Msg(receiver, selector, argtype, arg)
- register inst *receiver;
- register int selector;
- int argtype;
- char *arg;
- #ifdef BLAZING_SADDLES
- {
- register classFcn fcn; /* ptr to function within class function array */
- register char *retVal = (char *)1; /* value returned from function */
-
- if (fcn = ((classFcn *)receiver->classFcns)[selector]) {
- retVal = (char *)((*fcn)(receiver, argtype, arg));
- }
- }
- #else
- {
- classFcn *fcnPtr; /* ptr to function array within class description */
- classFcn fcn; /* ptr to function within class function array */
- char *retVal = (char *)1; /* value returned from function */
-
- if (receiver) {
- lastReceiver = (char *)receiver;
- lastClass = (char *)receiver->myClass->classId;
- if (fcnPtr = receiver->classFcns) { /* assign, test for NULL */
- lastSelector = (char *)selector;
- if ((selector >= 0) && (selector < receiver->nFcns)) {
- if (fcn = fcnPtr[selector]) { /* assign, test for NULL */
- retVal = (char *)((*fcn)(receiver, argtype, arg));
- } else
- #ifdef LOUD
- fprintf(stderr,"Msg: selector %d; NULL fcn\n",selector)
- #endif
- ;
- } else
- fprintf(stderr,"Msg: selector %d out of range receiver=%x id=%d nFcns=%d\n", selector,receiver,receiver->myClass->classId,receiver->nFcns);
- } else
- fprintf(stderr,"Msg: receiver %x has NULL classFcns selector=%d id=%d\n",
- receiver,selector,receiver->myClass->classId);
- } else
- fprintf(stderr,"Msg: NULL receiver selector=%d\n",selector);
- return retVal;
- }
- #endif /* BLAZING_SADDLES */
-